$(() => {
    let query = location.search;
    console.log("query =>", query.substr(1,query.length));
    let carousel_item = $(".carousel-inner");
    let carousel_indicators = $(".carousel-indicators");
    $.ajax({
        url: `http://touch.dujia.qunar.com/item?${query.substr(1,query.length)}`,
        type: 'GET',
        // data: {
        //     tm: 'pc_jrth',
        //     id: query,
        //     dep: '东莞'
        // },
        dataType: 'jsonp',
        beforeSend: function(){
            $(".content").css("display","none");
        },
        success: function(data){
            console.log(data);
            $(".content").css("display","block");
            let info = data.data.product;
            let ele = '';
            let btn = '';
            $(".endId").html(info.enId);
            $(info.feature.replace(/data-lazy/g,'src')).appendTo($(".feature"));
            info.imageInfos.map((v, i) => {
                if(i == 0){
                    ele = `
                        <div class="carousel-item active">
                            <img src="${v.bigUrl}" class="d-block w-100" alt="...">
                        </div>
                    `;               
                    btn = `<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="${i}" class="active" aria-current="true" aria-label="Slide ${i+1}"></button>`;
                }else{
                    ele = `
                        <div class="carousel-item">
                            <img src="${v.bigUrl}" class="d-block w-100" alt="...">
                        </div>
                    `;
                    btn = `<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="${i}" aria-label="Slide ${i+1}"></button>`;
                }
                $(".loading").css("display","none");
                $(ele).appendTo(carousel_item);
                $(btn).appendTo(carousel_indicators);
            })
            $(".price").html(info.adultprice);
            $(".title").html(info.name);  
            $(info.elderDetail).appendTo($(".level"))
            info.productFeatureEntities.map((v,i) => {
                if(i == 0){return ;};
                let imgs = `<img src="${v.imgUrls[0]}" />`;
                $(imgs).appendTo($(".desc"));
            })
        },
        error: function(err1){
            console.log(err1);
            $(".content").css("display","none");
            $(".loading").css("display","none");
            $(".close").css("display", 'block');
        }
    })
   
})